home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15410 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: nntp.earthlink.net!usenet
  2. From: brunop@earthlink.net (Peter Bruno)
  3. Newsgroups: comp.lang.c
  4. Subject: Q: Newbie using text files
  5. Date: Thu, 18 Apr 1996 20:04:46 GMT
  6. Organization: Earthlink Network, Inc.
  7. Message-ID: <4l6aqu$rfr@chile.it.earthlink.net>
  8. NNTP-Posting-Host: pool026.max12.new-york.ny.dynip.alter.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. I'm new to C programming so bear with me for a bit...
  12.  
  13. I do a lot of small programming projects at work, mostly to make my
  14. life easier, and I've been using QBasic.  I would like, however, to
  15. use a betting langauage if I could.  But, trying to input and
  16. processes text files in C seems a lot harder than in C, what with
  17. pointers and all.
  18.  
  19. My point, and I do have one, is it worth my time to learn C to process
  20. ASCII text files with fixed lenth fields, for sorting etc...
  21.  
  22. and could you suggest some routines for doing this...  in basic I just
  23. do the following:
  24.  
  25. open "foo.bar" for input as #1
  26. open "foo.out" for output as #2
  27. while not eof(1)
  28.     line input #1, row
  29.     FName = mid$(row, 1, 25)    'characters 1-25 are first name
  30.     LName = mid$(row, 26, 50)
  31.     test = mid$(LName, 26, 1)
  32.     if test < "M" then print #2, row    'if person's last name begins with
  33. character less then M print to output file, else we don't want them!
  34. wend
  35. close #1, #2
  36.  
  37. can someone (kind-hearted and forgiving of stupid questions) please
  38. offer suggestions on how to do this in C?  PLEASE!
  39.  
  40. thanks,
  41.  
  42. Peter Bruno
  43. brunop@earthlink.net
  44.     
  45.  
  46.